package com.example.service;

import com.example.entity.VideoHistory;
import com.example.entity.VideoLike;
import com.example.mapper.VideoLikeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*视频收藏业务处理
 */
@Service
public class VideoLikeService {

    @Resource
    private VideoLikeMapper videoLikeMapper;

    public void add(VideoLike videoLike) {
        videoLikeMapper.insert(videoLike);
    }

    public void deleteById(Integer id) {
        videoLikeMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(VideoLike videoLike) {
        videoLikeMapper.updateById(videoLike);
    }

    public VideoLike selectById(Integer id) {
        return videoLikeMapper.selectById(id);
    }

    public List<VideoLike> selectAll(VideoLike videoLike) {
        return videoLikeMapper.selectAll(videoLike);
    }

    public PageInfo<VideoLike> selectPage(VideoLike videoLike, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<VideoLike> videoLikeList = videoLikeMapper.selectAll(videoLike);
        return PageInfo.of(videoLikeList);
    }
}
